home *** CD-ROM | disk | FTP | other *** search
-
- ***************************************************
-
- // Listing 4 - MANIPT.CPP
- #include <iostream.h>
-
- /* 1 argument template */
- template <class T>
- class omanip1
- {
- ostream& (*_fn)(ostream&,T);
- T a1;
-
- public:
- omanip1(ostream& (*_f)(ostream&, T), T _a1) :
- _fn(_f), a1(_a1)
- {
- };
-
- friend ostream& operator<<(ostream& _s,omanip1& _f)
- {
- return (*_f._fn)(_s,_f.a1);
- };
- };
-
- /* Action function */
- static ostream& tem_test(ostream &o, int a)
- {
- o<<"Template test="<<a<<"!!";
- return o;
- }
-
- /* Manipulator function */
- omanip1<int> mytest(int i)
- {
- omanip1<int> rv(mytest,i);
- return rv;
- }
-
-
- /* Simple test program */
- main()
- {
- cout<<mytest(10)<<"\n";
- }
-
-
-